<?php
//--------------------------------BACKEND
function view_backend($config,$param) {
    $param['loggedin'] = true;
    view_backend_header($config, $param);
    ?>
    <h1>Hello!</h1>
    <p>
        <?php
        if (isset($_SESSION['logged'])) {
            echo $_SESSION['loginstatus'];
            //unset($_SESSION['loginstatus']);
        }
        ?>
    </p>    
    <?php
    view_backend_footer($config, $param);
}
//--------------------------------------HOME
require('_bckhome.php');
//--------------------------------------ABOUT
require('_bckabout.php');
//--------------------------------------CStudio
require('_bckcstudio.php');
//--------------------------------------SEKOLAH
require('_bcksekolah.php');
//---------------------------------------SANGGAR
require('_bcksanggar.php');
//---------------------------------------YAYASAN
require('_bckyayasan.php');
//--------------------------------------PRODUK
require('_bcktoko.php');
//---------------------------------------CONTACT
function view_bckcontact($config,$param) {
    $db = new db($config);
	$kontak = $db->query("SELECT * FROM kontak WHERE page ='contact'");
    $param['contact'] = true;
    $param['loggedin'] = true;
    view_backend_header($config, $param);
    //verifikasi isian gunakan javascript
    if (isset($_SESSION['editted'])) {
        echo '<div class="alert alert-warning">'.$_SESSION['editted'].'</div>';
        unset($_SESSION['editted']);
    }
    ?>
	<h3>Kontak</h3>
    <div id="kontak">
        <form method="post" action="<?php echo $config['home_url']."backend/edcontact"?>">
            <div>No Telp : <input type="text" name="notelp" value="<?php echo $kontak[0]['telp']; ?>" /></div>
            <div>Email : <input type="text" name="email" value="<?php echo $kontak[0]['email']; ?>" /></div>
			<div>Alamat : <textarea class="slimbck" name="alamat"><?php echo $kontak[0]['alamat']; ?></textarea></div>
            <div><input class="btn" type="submit" value="Ubah" name="ubah" /></div>
        </form>
	</div>
    <?php
    view_backend_footer($config, $param);
}
//--------------------------------FOOTER
function view_bckfoot($config,$param) {
    $db = new db($config);
    $result = $db->query("SELECT * FROM footer WHERE 1");
    $param['footer'] = true;
    $param['loggedin'] = true;
    view_backend_header($config, $param);
    ?>
    <?php
    //verifikasi isian gunakan javascript
    if (isset($_SESSION['editted'])) {
        echo '<div class="alert alert-warning">'.$_SESSION['editted'].'</div>';
        unset($_SESSION['editted']);
    }
    ?>
	<h3>Edit Footer</h3>
    <div id="footer">
        <form method="post" action="<?php echo $config['home_url']."backend/edfoot"?>">
            <div>Facebook : <div class="input-prepend"><span class="add-on">facebook.com/</span><input type="text" name="fb" value="<?php echo $result[0]['facebook']; ?>" /></div></div>
            <div>Twitter : <div class="input-prepend"><span class="add-on">@</span><input type="text" name="twitter" value="<?php echo $result[0]['twitter']; ?>" /></div></div>
            <div>Alamat : <input style="width:300px" type="text" name="alamat" value="<?php echo $result[0]['alamat']; ?>" /></div>
			<div>Nomor Kontak : <input type="text" name="kontak" value="<?php echo $result[0]['kontak']; ?>" /></div>
            <div><input class="btn" type="submit" value="Ubah" name="ubah" /></div>
        </form>
	</div>
    <?php
    view_backend_footer($config, $param);
}
//---------------------------------------USERS
require('_bckusers.php');
//---------------------------------------------LOGIN
function view_login($config,$param) {
    view_backend_header($config,$param);
    ?>
    <div class="container" style="width:340px;margin:20px auto">
        <form method="post" action="" class="well" style="width:300px;margin:0 auto">
            <div style="width:220px;margin:0 auto">
                <?php
                //verifikasi isian gunakan javascript
                if (isset($_SESSION['logoutstatus'])) {
                    echo '<div class="alert alert-success">'.$_SESSION['logoutstatus'].'</div>';
                    unset($_SESSION['logoutstatus']);
                } else if (isset($_SESSION['loginstatus'])) {
                    echo '<div class="alert alert-error">'.$_SESSION['loginstatus'].'</div>';
                    unset($_SESSION['loginstatus']);
                }
                ?>
                <label>Username</label>
                <input type="text" name="uname" class="span3">
                <label>Password</label>
                <input type="password" name="pwd" class="span3">
                <label></label>
                <input type="submit" name="submit" class="btn" style="display:block;margin:0 auto" value="Log In">
            </div>
        </form>
    </div>
    <?php
    view_backend_footer($config,$param);
}
//-----------------------------------SIDEBAR-HEADER
function view_backend_header($config, $param) {
    ?>
<!doctype html>
<html>
    <head>
        <meta name="robots" content="noindex,nofollow">
        <meta charset="UTF-8">
        <link rel="stylesheet" type="text/css" href="<?php echo $config['home_url']; ?>asset/bootstrap/css/bootstrap.min.css">
		<script src="<?php echo $config['home_url']; ?>asset/script/jquery-1.8.3.min.js"></script>
		<script src="<?php echo $config['home_url']; ?>asset/script/script.js"></script>
        <title>Balerupa Admin</title>
        <style type="text/css">
            body {
                padding-top: 60px; /* 60px to make the container go all the way to the bottom of the topbar */
            }
			.descbck{
				 width	: 650px;
				 height	: 150px;
				 resize	: vertical;
			}
			.slimbck{
				 width	: 650px;
				 height	: 75px;
				 resize	: vertical;
			}
        </style>
    </head>
    <body>
    <?php
    if (isset($param['loggedin'])) {
        $kutipan = isset($param['kutipan']) ? ' class="active"' : '';
        $aboutus = isset($param['aboutus']) ? ' class="active"' : '';
        $cstudio = isset($param['cstudio']) ? ' class="active"' : '';
        $bimbel = isset($param['bimbel']) ? ' class="active"' : '';
        $sanggar = isset($param['sanggar']) ? ' class="active"' : '';
        $yayasan = isset($param['yayasan']) ? ' class="active"' : '';
        $produk = isset($param['produk']) ? ' class="active"' : '';
        $contact = isset($param['contact']) ? ' class="active"' : '';
        $footer = isset($param['footer']) ? ' class="active"' : '';
		$pengguna = isset($param['pengguna']) ? ' class="active"' : '';
        ?>
        <div class="navbar navbar-inverse navbar-fixed-top">
          <div class="navbar-inner">
            <div class="container-fluid">
              <button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
              </button>
              <a class="brand" href="<?php echo $config['home_url'] ?>">Balerupa</a>
              <div class="nav-collapse collapse">
                <!--<p class="navbar-text pull-right">
                  Logged in as <a href="#" class="navbar-link">Username</a>
                </p>
                <ul class="nav">
                  <li class="active"><a href="#">Home</a></li>
                  <li><a href="#about">About</a></li>
                  <li><a href="#contact">Contact</a></li>
                </ul>-->
              </div><!--/.nav-collapse -->
            </div>
          </div>
        </div>
        <div class="container-fluid">
          <div class="row-fluid">
            <div class="span3">
              <div class="well sidebar-nav">
                <ul class="nav nav-list">
                  <li class="nav-header">Menu</li>
                  <li<?php echo $kutipan ?>>
                      <a href="<?php echo $config['home_url']."backend/home" ?>">Home</a>
                  </li>
                  <li<?php echo $aboutus ?>>
                      <a href="<?php echo $config['home_url']."backend/aboutus" ?>">About Us</a>
                  </li>
				  <li<?php echo $cstudio ?>>
                      <a href="<?php echo $config['home_url']."backend/cstudio" ?>">Creative Studio</a>
                  </li>
				  <li<?php echo $bimbel ?>>
                      <a href="<?php echo $config['home_url']."backend/bimbel" ?>">Sekolah</a>
                  </li>
                  <li<?php echo $sanggar ?>>
                      <a href="<?php echo $config['home_url']."backend/sanggar" ?>">Sanggar Budaya</a>
                  </li>
				  <li<?php echo $yayasan ?>>
                      <a href="<?php echo $config['home_url']."backend/yayasan" ?>">Yayasan</a>
                  </li>
				  <li<?php echo $produk ?>>
                      <a href="<?php echo $config['home_url']."backend/produk" ?>">Toko</a>
                  </li>
				  <li<?php echo $contact ?>>
                      <a href="<?php echo $config['home_url']."backend/contact" ?>">Contact</a>
                  </li>
				  <li<?php echo $footer ?>>
                      <a href="<?php echo $config['home_url']."backend/footer" ?>">Footer</a>
                  </li>
				  <li<?php echo $pengguna ?>>
                      <a href="<?php echo $config['home_url']."backend/pengguna" ?>">Pengguna</a>
                  </li>
                  <li class="nav-header">Logout</li>
                  <li><a href="<?php echo $config['home_url']."backend/logout" ?>">Logout</a></li>
                </ul>
              </div><!--/.well -->
            </div><!--/span-->
            <div class="span9">
              <div class="hero-unit">
        <?php
    }
}
//-----------------------FOOTER
function view_backend_footer($config, $param) {
    if (isset($param['loggedin'])) {
        ?>
              </div>
            </div><!--/span-->
          </div><!--/row-->
          <hr>
          <footer>
            <p>&copy; 2013</p>
          </footer>
        </div><!--/.fluid-container-->
        <?php
    }
    ?>
    </body>
</html>
    <?php
}
